<?php
abstract class AbstractController {
  
  public function __construct() {
    $this->handleAppState();
    //$this->routeAction();
  }
  
  public function routeAction($pAction) {
    if (!method_exists($this,$pAction)) { 
      throw NotSupportedActionException("Handler for ". $pAction. " hasn't been implemented");
    }  
    $this->$pAction();  
  }
  
  abstract public function defaultAction();  
  
  abstract public function handleAppState();
}

class AbstractControllerException extends Exception{};
class NotSupportedActionException extends AbstractControllerException{};